﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ConfigMeister
{
    public partial class SphereBox : Form
    {
        public SphereBox(Sphere mod)
        {
            InitializeComponent();

            textBox1.Text = mod.Name;
            numericUpDown9.Value = (decimal) mod.Pos.X;
            numericUpDown10.Value = (decimal) mod.Pos.Y;
            numericUpDown11.Value = (decimal) mod.Pos.Z;
            numericUpDown2.Value = (decimal) mod.Radius;

            comboBox4.Items.AddRange(MaterialBucket.GetList());
            if (MaterialBucket.Count > 0)
            {
                if (mod.Material != "")
                {
                    comboBox4.SelectedItem = mod.Material;
                }
                else
                {
                    comboBox4.SelectedIndex = 0;
                }
                return;
            }
            comboBox4.Enabled = false;
        }

        public Sphere Result
        {
            get
            {
                Sphere mod = new Sphere();
                mod.Name = textBox1.Text;
                mod.Pos.X = (double) numericUpDown9.Value;
                mod.Pos.Y = (double) numericUpDown10.Value;
                mod.Pos.Z = (double) numericUpDown11.Value;
                mod.Radius = (double) numericUpDown2.Value;

                mod.Material = comboBox4.SelectedItem.ToString();

                return mod;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (MaterialBucket.Count == 0)
            {
                MessageBox.Show("Nie istnieją żadne materiały. Zostanie utworzony i przypisany domyślny materiał. Materiały możesz edytować w Edytorze materiałów.", "Brak materiału");
                Material temp = new Material();
                MaterialBucket.Add(temp);
                comboBox4.Items.AddRange(MaterialBucket.GetList());
                comboBox4.SelectedIndex = 0;
            }

            Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
